using System;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using Xoohoo.Repositories.SqlServerEF.Entities;
using Xoohoo.Repositories.SqlServerEF.Mapping;

namespace Xoohoo.Repositories.SqlServerEF
{
	public class XoohooContext : DbContext
	{
		static XoohooContext()
		{ 
			Database.SetInitializer<XoohooContext>(null);
		}

        public XoohooContext()
            : base("ApplicationServices"){}

		public DbSet<Bulletin> Bulletins { get; set; }
		public DbSet<Permission> Permissions { get; set; }
		public DbSet<Role> Roles { get; set; }
		public DbSet<Site> Sites { get; set; }
		public DbSet<User> Users { get; set; }
		public DbSet<UserGroup> UserGroups { get; set; }
		public DbSet<UserModuleData> UserModuleDatas { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
		{
            modelBuilder.Conventions.Remove<IncludeMetadataConvention>();
			modelBuilder.Configurations.Add(new BulletinMap());
			modelBuilder.Configurations.Add(new PermissionMap());
			modelBuilder.Configurations.Add(new RoleMap());
			modelBuilder.Configurations.Add(new SiteMap());
			modelBuilder.Configurations.Add(new UserMap());
			modelBuilder.Configurations.Add(new UserGroupMap());
			modelBuilder.Configurations.Add(new UserModuleDataMap());
		}
	}
}

